package com.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class UploadFileConfig implements WebMvcConfigurer {

    @Value("${download.dir}")
    private  String downloadDir;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
         //如果在地址访问  :8080/upload/... 就会跑到哪个downloadDir目录
         registry.addResourceHandler("/upload/**").addResourceLocations("file:"+downloadDir);
    }
}
